package logique.programme;

import logique.solution.Solution;

public class Contrainte extends CombinaisonLineaire {

	private String operateur;

	private double termeConstant;
	
	public Contrainte (String operateur, double termeConstant) {
		super();
		this.operateur = operateur;
		this.termeConstant = termeConstant; 
	}
	
	public void addTermeConstant (double d) {
		termeConstant -= d;
	}

	public boolean estSatisfaite(Solution s) {
		if (operateur.equals("=="))
			return evaluer(s) == termeConstant;
		else if (operateur.equals("<="))
			return evaluer(s) <= termeConstant;
		else if (operateur.equals(">="))
			return evaluer(s) >= termeConstant;
		else if (operateur.equals("<"))
			return evaluer(s) < termeConstant;
		else if (operateur.equals(">"))
			return evaluer(s) > termeConstant;
		return false;
	}

	public String getOperateur() {
		return operateur;
	}

	public double getTermeConstant() {
		return termeConstant;
	}
	public void setTermeConstant(double d) {
		termeConstant = d;
	}
	public String toString () {
		return super.toString() + "  " + operateur + "  " + termeConstant;
	}
	public void afficher () {
		super.afficher();
		System.out.print("  " + operateur + "  " + termeConstant);
	}
	public Contrainte getCopy() {
		Contrainte c = new Contrainte(getOperateur(), getTermeConstant());
		return c;
	}
	
}